home *** CD-ROM | disk | FTP | other *** search
- Path: news.cyberhighway.net!usenet
- From: mjellis@cyberhighway.net
- Newsgroups: comp.lang.c
- Subject: Re: command line argument help
- Date: 29 Jan 1996 14:07:40 GMT
- Organization: Idaho Central Intechange
- Message-ID: <4eikbc$cs9@host-3.cyberhighway.net>
- References: <4edfth$ok@muss.CIS.McMaster.CA> <4egi4nINNncr@keats.ugrad.cs.ubc.ca>
- Reply-To: mjellis@cyberhighway.net
- NNTP-Posting-Host: rpm1-28.cyberhighway.net
- X-Newsreader: IBM NewsReader/2 v1.2.5
-
- In <4egi4nINNncr@keats.ugrad.cs.ubc.ca>, c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) writes:
- >In article <4edfth$ok@muss.CIS.McMaster.CA>, <shadowfax> wrote:
- > >to all the c gods out there:
- > >
- > >i am not having too much success with command line arguments. i am
- > >trying to make a simple sumation executable for dos. i am using borland
- > >c++ v3.1. what i want as the end result is the user just types:
- > >
- > >c:\> sum 6 3
- >
- >Get a decent shell that can do arithmetic.
- >
- > echo $((6 + 3))
- >--
- >
-
- Use something like the following:
-
- #include <stdio.h>
- #include <stdlib.h>
-
- void main(int argc, char *argv[])
- {
- double a; /* First Operand */
- double b; /* Second Operand */
- a = strtod(argv[1],NULL); /* Converts a string to a float a */
- b = strtod(argv[2],NULL); /* Converts a string to a float b */
- printf("%f",(a + b));
- }
-
- I'll leave the error checking up to you.
-
- John Ellis
- mjellis@cyberhighway.net
- john@ici.usa.net
- Idaho Central Interchange BBS: (208) 677-2028
-
-